﻿using MrPP.Common;
using MrPP.Helper;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MrPP.SerriedCabinet
{
    public class ShelveModel : GDGeek.Singleton<ShelveModel>, IShelveModel
    {
        [SerializeField]
        private GameObject _viewModel;
       
     

        private void doCode(string sn)
        {  
            this.doScanning(sn);   
        }
           
        public void testScaning(string sn)
        {
            this.doScanning(sn);
        }

        public void testLocation(Location location) {

            this.doSelected(location.location);
        }

        public void testBinding() {
            this.doBinding(0);
        }
        public IShelveModel viewModel {

            get {
                return _viewModel.gameObject.GetComponent<IShelveModel>();
            }
        }
        public void doBinding(IntId id)
        {
            viewModel.doBinding(id.value);
        }
        public void doBinding(int id)
        {
            viewModel.doBinding(id);
        }

        public void doLast()
        {
            viewModel.doLast();
        }

        public void doNext()
        {
            viewModel.doNext();
        }

        public void doPlay()
        {
            viewModel.doPlay();
        }

        public void doScanning(string sn)
        {
            viewModel.doScanning(sn);
        }

     
        public void doSelected(BoxLocation location)
        {

            viewModel.doSelected(location);
        }

        public void doStop()
        {

            viewModel.doStop();
        }

        internal void open()
        {
            QRCodeManager.Instance.onRecevie += doCode;
        }

        internal void close()
        {
            QRCodeManager.Instance.onRecevie -= doCode;
        }

        public void doReset()
        {
            viewModel.doReset();
        }
    }
}